# -*- mode: ruby -*-
# vi: set ft=ruby :

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
nodes = {
          'controller' => [1,200],
          'compute' => [1,201],
}

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
    config.vm.box = "precise64"
    #ubuntu image 64bit
    config.vm.box_url = "http://files.vagrantup.com/precise64.box"
    config.vm.usable_port_range = 2800..2900
    nodes.each do | prefix, (count,ip_start)|
        #prefix is controller
        #count is 1
        #ip_start is 200
        count.times do |i|
        #create hostname "controller-01"
        hostname = "%s-%02d" % [prefix, (i+1)]
        config.vm.define "#{hostname}" do |box|
            box.vm.hostname = "#{hostname}.book"
            box.vm.network  :private_network, ip: "172.16.0.#{ip_start + i}", :netmask => "255.255.0.0"
            box.vm.network  :private_network, ip: "10.10.0.#{ip_start + i}", :netmask => "255.255.0.0"
            box.vm.network  :private_network, ip: "192.168.100.#{ip_start + i}", :netmask => "255.255.255.0"
            box.vm.provider :virtualbox do |vbox|
                #default
                if prefix == "controller"
                   vbox.customize ["modifyvm", :id, "--memory", 2048]
                   vbox.customize ["modifyvm", :id, "--cpus", 1]
                end
                if prefix == "compute"
                   vbox.customize ["modifyvm", :id, "--memory", 3172]
                   vbox.customize ["modifyvm", :id, "--cpus", 2]
                end

            end
        end
    end
    end
end
